package com.itheima.jobs;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.OrderSettingService;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


public class ClearMember {
//定时删除预约：定义每月最后一天凌晨2点执行一次清理任务，清理上个月的预约信息；
    @Reference
    private OrderSettingService orderSettingService;
    public void clearMember() throws ParseException {
        //获取上个月今天的日期；
        Date date = new Date();
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.MONTH,-1);
        Date time = c.getTime();
        String s = new SimpleDateFormat("yyyy-MM-dd").format(time);
        System.out.println(s);
        //调用删除方法；
        try {
            orderSettingService.delete(s);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
